package com.onpositive.gamemaker.editor;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.w3c.dom.views.AbstractView;

public class GameCreatorEditorPlugin extends AbstractUIPlugin {

	public static final String PLUGIN_ID = "com.onpositive.gamemaker.editor";
	private static BundleContext context;
	private static GameCreatorEditorPlugin plugin;

	static BundleContext getContext() {
		return context;
	}



	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext bundleContext) throws Exception {
		super.start(bundleContext);
		GameCreatorEditorPlugin.context = bundleContext;
		plugin = this;
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext bundleContext) throws Exception {
		super.stop(bundleContext);
		GameCreatorEditorPlugin.context = null;
		plugin = null;
	}

	public static void logError(Exception e)
	{
		getDefault().getLog().log(new Status(Status.ERROR,PLUGIN_ID,e.getLocalizedMessage(),e));
	}
	

	/**
	 * Returns the shared instance
	 *
	 * @return the shared instance
	 */
	public static GameCreatorEditorPlugin getDefault() {
		return plugin;
	}

	

	public static void logError(String message)
	{
		logError(new RuntimeException(message));
	}

}
